# Maintainer: Martell Malone <martellmalone@gmail.com>

pkgname=bzr
pkgver=2.6.0
pkgrel=3
pkgdesc="Bazaar is a version control system that helps you track project history over time and to collaborate easily with others."
arch=('i686' 'x86_64')
url="http://bazaar.canonical.com/en/"
license=('GPL')
groups=('VCS')
depends=('python2')
#optdepends=('python-paramiko: for sftp support')
source=("http://launchpad.net/${pkgname}/${pkgver%.*}/${pkgver}/+download/${pkgname}-${pkgver}.tar.gz"{,.sig}
        0001-setup.py-man-install.patch
        0002-add-msys2-certs-location.patch)
md5sums=('28c86653d0df10d202c6b842deb0ea35'
         'SKIP'
         'a57fd2fba54576244e4a70c0b0ca77a5'
         'b1c1a224402e393899a2953ca4b2375b')

prepare(){
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-setup.py-man-install.patch
  patch -p1 -i ${srcdir}/0002-add-msys2-certs-location.patch
  sed -e 's|/usr/bin/env python|/usr/bin/env python2|' \
      -i bzrlib/{plugins/bash_completion/bashcomp.py,tests/ssl_certs/create_ssls.py,patiencediff.py,_patiencediff_py.py}
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  python2 setup.py build
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  python2 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1

  # bash-completion
  install -D -m644 contrib/bash/bzr "${pkgdir}/usr/share/bash-completion/completions/bzr"
}
